<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>自体输血</title>
    <link rel="shortcut icon" type="image/x-icon" href="/img/favicon.ico">
    <link rel="stylesheet" href="/element-theme/blue/index.css">
    <link href="https://cdn.jsdelivr.net/npm/element-ui@2.15.12/lib/theme-chalk/index.min.css" rel="stylesheet">
</head>
<body>

<div class="data-manage-table">
    <template>
        <el-form ref="form" :inline="true" style="padding:20px 20px 0 20px;">
            <el-form-item label="申请单号">
                <el-input v-model="pagination.transfusionNumber" clearable placeholder="请输入输血申请单号"></el-input>
            </el-form-item>

            <el-form-item label="身份证号">
                <el-input v-model="pagination.patientIdcard" clearable placeholder="请输入病人身份证号"></el-input>
            </el-form-item>

            <el-form-item label="血液成分">
                <el-select v-model="pagination.transfusionType" placeholder="请选择或输入血液成分" clearable filterable @blur="selectBlur"
                @clear = "selectClearComponent" @change="selectChangeComponent">
                    <el-option v-for="(item,index) in transfusionTypeList" :key="item.code" :label="item.composition" :value="item.code">
                    </el-option>
                </el-select>
            </el-form-item>
            
            <el-form-item label="血量">
                <el-select v-model="pagination.transfusionVolume" clearable placeholder="请选择血量">
                    <el-option v-for="item in transfusionVolumeList" :key="item.code" :label="item.size" :value="item.code">
                    </el-option>
                </el-select>
            </el-form-item>


            <el-form-item>
                <el-button type="primary" @click="getByQueryPage(1)">搜索</el-button>
            </el-form-item>

            <el-form-item>
                <el-button type="info" @click="getByQueryPage()">重置</el-button>
            </el-form-item>

            <el-form-item>
                <el-button type="danger" @click="batchDelete()">批量删除</el-button>
            </el-form-item>

            <el-table ref="transfusionAutoTable" :data="tableData" style="width: 100%" border
                      :header-cell-style="{'text-align': 'center','background': '#eef1f6'}" highlight-current-row fit>
                <el-table-column type="selection"></el-table-column>
                <el-table-column prop="transfusionNumber" label="输血申请单号" align="center">
                    <template slot-scope="scope">
                        <el-button type="text"  @click="viewInfo(scope.row)">{{ scope.row.transfusionNumber }}</el-button>
                    </template>
                </el-table-column>
                <el-table-column prop="patientIdcard" label="患者身份证号" align="center"></el-table-column>
                <el-table-column prop="transfusionType" label="输血类型" align="center">
                    <template slot-scope="scope">
                        {{ getTransfusionTypeName(scope.row.transfusionType) }}
                    </template>
                </el-table-column>
                <el-table-column prop="transfusionVolume" label="血量" align="center">
                    <template slot-scope="scope">
                        {{ getBloodSizeName(scope.row.transfusionVolume) }}
                    </template>
                </el-table-column>
                <!--相关操作-->
                <el-table-column fixed="right" label="操作"  align="center">
                    <template slot-scope="scope">
                        <el-button size="mini" type="primary" @click="Match(scope.row)" align="center">分配</el-button>
                        <el-dialog title="输血信息确认" :visible.sync="bloodInfoFormVisible" :modal="false">
                            <el-descriptions :content-style="rowCenter" :label-style="rowCenter" class="margin-top" :column="2" :size="size" border>
                                <el-descriptions-item>
                                    <template slot="label" align="center" >
                                    血液编号
                                    </template>
                                    {{ bloodInfoForm.bloodId }}
                                </el-descriptions-item>
                                <el-descriptions-item>
                                    <template slot="label" align="center" >
                                    身份证号
                                    </template>
                                    {{ bloodInfoForm.patientIdcard }}
                                </el-descriptions-item>
                                <el-descriptions-item>
                                    <template slot="label">
                                        血装编号条码
                                    </template>
                                    {{ bloodInfoForm.barcode }}
                                    </el-descriptions-item>
                                  <el-descriptions-item>
                                    <template slot="label" align="center" >
                                      扩展码
                                    </template>
                                    {{ bloodInfoForm.extendCode }}
                                  </el-descriptions-item>
                                  <el-descriptions-item>
                                    <template slot="label" align="center" >
                                      血液成分
                                    </template>
                                    {{ bloodInfoForm.bloodComponent }}
                                  </el-descriptions-item>
                                  <el-descriptions-item>
                                      <template slot="label">
                                        血量
                                      </template>
                                      {{ bloodInfoForm.bloodCount }}
                                    </el-descriptions-item>
                                    <el-descriptions-item>
                                        <template slot="label" align="center" >
                                        ABO血型
                                        </template>
                                        {{ bloodInfoForm.aboBloodType }}
                                      </el-descriptions-item>
                                      <el-descriptions-item>
                                        <template slot="label" align="center" >
                                          RH血型
                                        </template>
                                        {{ bloodInfoForm.rhBloodType }}
                                      </el-descriptions-item>
                                      <el-descriptions-item>
                                          <template slot="label">
                                            血液位置
                                          </template>
                                          {{ bloodInfoForm.bloodLocation }}
                                        </el-descriptions-item>
                                        <el-descriptions-item>
                                            <template slot="label">
                                              状态
                                            </template>
                                            {{ bloodInfoForm.state }}
                                          </el-descriptions-item>
                                        <el-descriptions-item>
                                            <template slot="label" align="center" >
                                            失效时间
                                            </template>
                                            {{ bloodInfoForm.failureTime }}
                                          </el-descriptions-item>
                                          <el-descriptions-item>
                                            <template slot="label" align="center" >
                                              采集时间
                                            </template>
                                            {{ bloodInfoForm.collectTime }}
                                          </el-descriptions-item>
                                </el-descriptions>

                                <div slot="footer" class="dialog-footer" align="center">
                                    <el-button type="danger" @click="cancel()">取消分配</el-button>
                                    <el-button type="primary" @click="determine()">确定分配</el-button>
                                </div>
                            </el-dialog>
                            </template>
                </el-table-column>
            </el-table>


            <!--分页组件-->
            <div class="pagination-container">
                <el-pagination
                        class="pagiantion"
                        @size-change="handleSizeChange"
                        @current-change="handleCurrentChange"
                        :current-page="pagination.currentPage"
                        :page-sizes="[5,10,15]"
                        :page-size="pagination.pageSize"
                        layout="total, sizes, prev, pager, next, jumper"
                        :total="pagination.total"
                        style="text-align: center; margin-top: 20px;">
                </el-pagination>
            </div>

            <el-dialog title="自体输血申请" center :visible.sync="dialogAutoVisible" width="60%">
                <!-- 内容的主体区域 -->
                <el-descriptions :content-style="rowCenter" :label-style="rowCenter" class="margin-top"  :column="3"  border>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            输血申请单号
                        </template>
                        {{ autoSample.transfusionNumber }}</el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            病案号
                        </template>
                        {{autoSample.medicalRecordNumber}}</el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            临床诊断
                        </template>
                        {{autoSample.diagnosisResult}}</el-descriptions-item>
                    <el-descriptions-item>
                    <template slot="label" align="center" >
                        拟备血量
                    </template>
                    {{autoSample.prepareVolume}}</el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            血液成分
                        </template>
                        {{ autoSample.transfusionType }}</el-descriptions-item>
                        <el-descriptions-item>
                            <template slot="label" align="center" >
                                鉴定者
                            </template>
                            {{autoSample.appraiser}}</el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            血量
                        </template>
                        {{ autoSample.transfusionVolume }}</el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            体重
                        </template>
                        {{autoSample.weight}}</el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            血小板计数
                        </template>
                        {{autoSample.plateletCount}}</el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            血红蛋白
                        </template>
                        {{autoSample.hemoglobin}}</el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            红细胞比容
                        </template>
                        {{autoSample.hematocrit}}</el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            申请医师
                        </template>
                        {{autoSample.applyDoctor}}</el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            申请日期
                        </template>
                        {{autoSample.applyTime}}</el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            鉴定血型
                        </template>
                        {{autoSample.identifyBloodType}}</el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            鉴定Rho
                        </template>
                        {{autoSample.identifyRho}}</el-descriptions-item>
                        <el-descriptions-item>
                            <template slot="label" align="center" >
                                拟手术日期
                            </template>
                            {{autoSample.surgeryTime}}</el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            回输时间
                        </template>
                        {{autoSample.backTime}}</el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            回输量
                        </template>
                        {{autoSample.backVolume}}</el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            取血人
                        </template>
                        {{autoSample.bloodTaker}}</el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            发血人
                        </template>
                        {{autoSample.bloodSender}}</el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            采血者
                        </template>
                        {{autoSample.bloodCollector}}</el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            心功能
                        </template>
                        {{autoSample.heartFunction}}</el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            肺功能
                        </template>
                        {{autoSample.lungFunction}}</el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            肝功能
                        </template>
                        {{autoSample.liverFunction}}</el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            肾功能
                        </template>
                        {{autoSample.renalFunction}}</el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            自体输血同意书
                        </template>
                        {{autoSample.isAutobloodtranAgreement}}</el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            备注
                        </template>
                        {{autoSample.note}}</el-descriptions-item>
    
                    <el-descriptions-item>
                    <template slot="label" align="center" >
                            驳回原因
                        </template>
                        {{ autoSample.getRejectReason }}
                        </el-descriptions-item>
                </el-descriptions>
            </el-dialog>

    </template>
</div>


<script src="../../../js/vue.min.js"></script>
<script src = "../../../js/2.15.12/index.js"></script>
<link href = "../../../css/2.15.12/index.css" rel="stylesheet">
<script src="../../../plugins/axios-0.27.2/axios.min.js"></script>
<script src="../../../icons/iconfont.js"></script>
<script src="../../../js/httpVueLoader.js"></script>
<script>Vue.prototype.$ELEMENT = { size: 'medium' };</script>
<script>(
    function () {
        new Vue({
            el: '.data-manage-table',
            data() {
                return {
                    // 描述列表文字居中
                    rowCenter:{
                        "text-align":"center"
                    },

                    // 当前用户登录信息
                    user: {
                        "accountNonExpired": true,
                        "accountNonLocked": true,
                        "credentialsNonExpired": true,
                        "enable": false,
                        "enabled": false,
                        "jobnum": "tom",
                        "menuUrls": {
                            "menu": [{
                                "urls": [{
                                    "id": "11",
                                    "title": "11",
                                    "url": "/pages/error/403.html",
                                    "titleflag": "error"
                                }], "title": "testerror", "titleflag": "error"
                            }, {
                                "urls": [{
                                    "id": "22",
                                    "title": "5-5",
                                    "url": "/pages/error/505.html",
                                    "titleflag": "testerror"
                                }], "title": "testerror2", "titleflag": "testerror"
                            }]
                        },
                        "noLocked": false,
                        "personalization": {
                            "asideFold": false,
                            "mainTabsHeaderFixed": true,
                            "asideControlOpen": false,
                            "headerSkin": "colorful",
                            "headerFixed": false,
                            "skin": "brown",
                            "asideSkin": "dark",
                            "asideControlFixed": true
                        },
                        "username": "tom"
                    },

                    // abo血型
                    aboBloodTypeList : '',

                    // rh血型
                    rhBloodTypeList : '',

                    // 血液类型
                    bloodComponentList : '',

                    // 输血量列表
                    transfusionVolumeList : '',

                    //输血类型列表
                    transfusionTypeList : '',

                    //自体输血信息描述列表开关
                    dialogAutoVisible : false,

                    //自体输血信息描述列表
                    autoSample:{},

                    // 输血申请单号用于之后添加取血记录
                    transfusionNumberIndex : '',

                    //分页相关信息
                    pagination: {
                        currentPage : 1, // 当前页码
                        pageSize : 5, // 每页显示记录数
                        total : 0, // 总记录数
                        //查询条件
                        transfusionNumber: '', // 输血申请单号
                        patientIdcard: '',   // 身份证号
                        transfusionType : '',
                        transfusionVolume : '',
                    },

                    //嵌套dialog表格状态
                    bloodInfoFormVisible : false,

                    // 配血确认信息表格
                    bloodInfoForm : {
                        bloodId : '',
                        patientIdcard: '',
                        barcode : '',
                        extendCode : '',
                        bloodComponent : '',
                        bloodCount : '',
                        aboBloodType : '',
                        rhBloodType : '',
                        failureTime : '',
                        collectTime : '',
                        state : '',
                        bloodLocation : '',
                    },

                    size : '',


                    //表格信息
                    tableData: [],

                    //匹配表格信息
                    matchBlood: [],

                    // 血液匹配信息分页
                    currentPageBlood: 1,
                    pagesizeBlood: 1,
                }
            },

            //自动触发写入的函数
            created() {
                this.getByQueryPage();
            },

            mounted(){
                this.getBloodSize();
                this.getBloodLocation();
                this.getAboBloodType();
                this.getRhBloodType();
                this.getBloodComponent();
                this.getTransfusionType();
                this.getState();
                this.user = sessionStorage.getItem("user") ? JSON.parse(sessionStorage.getItem("user")) : {};
            },

            methods: {
                // 血液匹配信息分页
                handleSizeChangeBlood: function (pagesizeBlood) {
                    this.pagesizeBlood = pagesizeBlood;
                },
                handleCurrentChangeBlood: function (currentPageBlood) {
                    this.currentPageBlood = currentPageBlood;
                },

                selectBlur(e){
                        if (e.target.value !== ''){
                            this.pagination.state = e.target.value;
                            this.$forceUpdate() //强制更新
                        }
                    },

                    // 清空血液成分
                    selectClearComponent(){
                        this.pagination.transfusionType = ''
                        this.$forceUpdate();
                    },

                    // 输入血液成分
                    selectChangeComponent(val){
                        this.pagination.transfusionType = val
                        this.$forceUpdate();
                    },


                // 查看自体输血详情描述列表
                viewInfo(row){
                    this.autoSample.transfusionNumber = row.transfusionNumber;
                    this.autoSample.medicalRecordNumber = row.medicalRecordNumber;
                    this.autoSample.diagnosisResult = row.diagnosisResult;
                    this.autoSample.prepareVolume = row.prepareVolume;
                    this.autoSample.appraiser = row.appraiser;
                    this.autoSample.weight = row.weight;
                    this.autoSample.plateletCount = row.plateletCount;
                    this.autoSample.hemoglobin = row.hemoglobin;
                    this.autoSample.hematocrit = row.hematocrit;
                    this.autoSample.applyDoctor = row.applyDoctor;
                    this.autoSample.applyTime = row.applyTime;
                    this.autoSample.bloodTaker = row.bloodTaker;
                    this.autoSample.bloodSender = row.bloodSender;
                    this.autoSample.bloodCollector = row.bloodCollector;
                    this.autoSample.heartFunction = row.heartFunction;
                    this.autoSample.lungFunction = row.lungFunction;
                    this.autoSample.renalFunction = row.renalFunction;
                    this.autoSample.isAutobloodtranAgreement = row.isAutobloodtranAgreement;
                    this.autoSample.note = row.note;
                    this.autoSample.surgeryTime = row.surgeryTime;
                    this.autoSample.backTime = row.backTime;
                    this.autoSample.backVolume = row.backVolume;
                    this.autoSample.getRejectReason = row.getRejectReason;
                    this.autoSample.identifyBloodType = this.getAboBloodName(row.identifyBloodType);
                    this.autoSample.identifyRho = this.getRhBloodName(row.identifyRho);
                    this.autoSample.transfusionType = this.getTransfusionTypeName(row.transfusionType);
                    this.autoSample.transfusionVolume = this.getBloodSizeName(row.transfusionVolume);
                    this.dialogAutoVisible = true;
                },

                  //批量删除
                  batchDelete() {
                    if(JSON.parse(JSON.stringify(this.$refs.transfusionAutoTable.selection)).length==0){
                        this.$notify({
                            title: '温馨提示：',
                            message: '您未选中数据，请重新操作！！！',
                            type: 'warning'
                        });
                        return;
                    }
                    let checkArr = JSON.parse(JSON.stringify(this.$refs.transfusionAutoTable.selection));  // 存储了勾选到的数据
                    var ids=new Array()
                    for(var i=0;i<checkArr.length;i++){
                        ids[i]=checkArr[i].id;
                    }
                    console.log("打印所选编号")
                    console.log(ids)
                    // let data={ids:ids}
                    //批量删除
                    this.$confirm('确定删除这些数据吗, 是否继续?', '批量删除', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning'
                    }).then(() => {
                        axios({
                            url: '/transfusionAutologous/normal/batchDelete1',
                            method: 'put',
                            dataType: 'json',
                            data:ids
                        }).then(res => {
                            if (res.data.code === '200') {
                                this.$notify({
                                    tile: '温馨提示',
                                    message: '批量删除成功！！！',
                                    type: 'success'
                                })
                                this.getByQueryPage(0);
                            } else {
                                this.$notify({
                                    tile: '警告',
                                    message: '删除出错',
                                    type: 'warning'
                                })
                            }
                        }).catch(err => {
                            this.$notify.error({
                                title: '错误',
                                message: '删除失败',
                            })
                        });
                    }).catch(() => {
                        this.$message({
                            type: 'info',
                            message: '已取消删除'
                        });
                    });
                },

                //分页查询
                getByQueryPage:function(flag){
                    if (flag != 1) {
                        this.pagination.transfusionNumber = '';
                        this.pagination.patientIdcard = '';
                        this.pagination.transfusionType = '';
                        this.pagination.transfusionVolume = '';
                        this.pagination.currentPage = 1;
                    }
                    axios.get('/transfusionAutologous/normal/lrz/' + this.pagination.currentPage + '/' + this.pagination.pageSize,
                        {
                            params:{
                                transfusionNumber : this.pagination.transfusionNumber,
                                patientIdcard : this.pagination.patientIdcard,
                                transfusionType : this.pagination.transfusionType,
                                transfusionVolume : this.pagination.transfusionVolume,
                            }
                        }).then((res)=>{
                        if (res.data.code === '200') {
                            this.pagination.pageSize = res.data.data.size;
                            this.pagination.currentPage = res.data.data.current;
                            this.pagination.total = res.data.data.total;
                            this.tableData = Object.values(res.data.data.records);
                        } else{
                            this.$message.success('查询失败');
                        }
                    });
                },

                // 分页查询 每页显示多少条数据
                handleSizeChange:function(pageSize){
                    this.pagination.pageSize = pageSize;
                    this.getByQueryPage(1);
                },

                // 分页查询 切换页码
                handleCurrentChange:function(currentPage){
                    this.pagination.currentPage = currentPage;
                    //执行查询
                    this.getByQueryPage(1);
                },


                //血液分配
                Match(row) {
                    // 先确认是否已经分配
                    axios.get('/bloodTake/normal/checkRecords', {
                        params : {
                            transfusionType : '自体血',
                            patientIdcard : row.patientIdcard,
                            bloodCount :  row.transfusionVolume,
                            bloodComponent : row.transfusionType,
                        }
                    }).then((res)=>{
                        // 代表没有记录
                        if (res.data.data == 0){
                            axios.get('/autologousBlood/normal/getAutoBloodInfo',
                                {
                                    params:{
                                        patientIdcard : row.patientIdcard,
                                        bloodCount : row.transfusionVolume,
                                        bloodComponent : row.transfusionType,
                                        collectTime : this.getNowTime(),
                                        failureTime : this.getNowTime(),
                                    }
                                }).then((res)=> {
                                    if (res.data.data != null){
                                        console.log("自体血信息匹配");
                                        console.log(res.data.data);
                                        this.transfusionNumberIndex = row.transfusionNumber;
                                        this.bloodInfoForm.bloodId = res.data.data.bloodId;
                                        this.bloodInfoForm.patientIdcard = res.data.data.patientIdcard;
                                        this.bloodInfoForm.barcode = res.data.data.barcode;
                                        this.bloodInfoForm.extendCode = res.data.data.extendCode;
                                        this.bloodInfoForm.bloodComponent = this.getBloodComponentName(res.data.data.bloodComponent);
                                        this.bloodInfoForm.bloodCount = this.getBloodSizeName(res.data.data.bloodCount);
                                        this.bloodInfoForm.aboBloodType = this.getAboBloodName(res.data.data.aboBloodType);
                                        this.bloodInfoForm.rhBloodType = this.getRhBloodName(res.data.data.rhBloodType);
                                        this.bloodInfoForm.failureTime = res.data.data.failureTime;
                                        this.bloodInfoForm.collectTime = res.data.data.collectTime;
                                        this.bloodInfoForm.state = this.getStateName(res.data.data.state);
                                        this.bloodInfoForm.bloodLocation = this.getBloodLocationName(res.data.data.bloodLocation);
                                        this.bloodInfoFormVisible = true
                                    } else {
                                        this.$notify({
                                            title : '消息',
                                            message : '未找到匹配的血液信息',
                                            type : 'success'
                                        })
                                    }
                            });
                           
                        }
                        else{
                            this.$notify({
                                title : '消息',
                                message : '已经分配血液了',
                                type : 'success'
                            })
                        }
                    })
                },


                // 发血确认按钮
                determine(){
                    // 关闭血液信息
                    this.bloodInfoFormVisible = false;
                    // 更改自体输血信息表信息
                    axios({
                        method : 'put',
                        url : '/autologousBlood/normal/setAutoBloodInfoState',
                        data : JSON.stringify({
                            bloodId : this.bloodInfoForm.bloodId,
                            state : '28' //28代表待取血
                        }),
                        headers : {
                            'Content-Type' : 'application/json;charset=UTF-8'
                        }
                    }).then((res)=>{
                        if (res.data.code === '200'){
                            this.$notify({
                                title : '消息',
                                message : res.data.data,
                                type : 'success'
                            })
                        }
                    })

                    // 增加一条取血记录
                    axios({
                        method : 'post',
                        url : '/bloodTake/normal/addRecord',
                        data : JSON.stringify({
                            bloodId : this.bloodInfoForm.bloodId,
                            // transfusionNumber : this.bloodInfoForm.transfusionNumber,
                            transfusionType : '自体血',
                            transfusionNumber : this.transfusionNumberIndex,
                            bloodComponent : this.getBloodComponentCode(this.bloodInfoForm.bloodComponent),
                            bloodType : this.bloodInfoForm.aboBloodType + this.bloodInfoForm.rhBloodType,
                            bloodCount : this.getBloodSizeCode(this.bloodInfoForm.bloodCount),
                            patientIdcard : this.bloodInfoForm.patientIdcard,
                            state : '28', // 28代表待取血
                            isDeleted : 0 //0代表未删除 
                        }),
                        headers : {
                            'Content-Type' : 'application/json;charset=UTF-8'
                        }
                    }).then((res)=>{
                        if (res.data.code === '200'){
                            this.$notify({
                                title : '消息',
                                message : res.data.data,
                                type : 'success'
                            })
                        }
                    })

                    // 发送消息通知
                    var sendTime = this.getNowTime();
                    console.log('发送时间：')
                    console.log(sendTime);
                    var text = '血液编号:'+  this.bloodInfoForm.bloodId + '血装编号:' +  this.bloodInfoForm.barcode + '血袋位置:' + this.bloodInfoForm.bloodLocation
                    var state = '未读' // 0代表未读
                    var isDeleted = 0 // 0代表未被删除
                    axios({
                        url : '/msgText/normal/addMsgText',
                        method : 'post',
                        data : JSON.stringify({
                            sendTime : sendTime,
                            doctorJobnum : this.user.jobnum,
                            text : text,
                            state : state,
                            isDeleted : isDeleted,
                        }),
                        headers : {
                            'Content-Type' : 'application/json;charset=UTF-8'
                        }
                    }).then((res)=>{
                        this.$notify({
                            title : '成功',
                            message : '取血消息发送成功',
                            type : 'success',
                        })
                    })
                },

                // 发血取消按钮
                cancel(){
                    this.bloodInfoForm.bloodId = '';
                    this.bloodInfoForm.patientIdcard = '';
                    this.bloodInfoForm.barcode = '';
                    this.bloodInfoForm.extendCode = '';
                    this.bloodInfoForm.bloodComponent = '';
                    this.bloodInfoForm.bloodCount = '';
                    this.bloodInfoForm.aboBloodType = '';
                    this.bloodInfoForm.rhBloodType = '';
                    this.bloodInfoForm.failureTime = '';
                    this.bloodInfoForm.collectTime = '';
                    this.bloodInfoForm.state = '';
                    this.bloodInfoForm.bloodLocation = '';
                    this.bloodInfoFormVisible = false;
                },

                // 获取血量字典
                getBloodSize(){
                        axios.get('/bloodSize/normal/getName1')
                            .then((res)=>{
                                if (res.data.code === '200') {
                                    this.transfusionVolumeList = res.data.data
                                } else {
                                    this.$notify.error({
                                        title: '错误',
                                        message: '获取数据失败',
                                    })
                                }
                            })
                        },
                
                    // 将表格中bloodCount字段的code转换成size
                    getBloodSizeName(code){
                        for (var i = 0; i < this.transfusionVolumeList.length; i++) {
                            if (this.transfusionVolumeList[i].code == code) { //dictValue，dictLabel保持和上面定义一致
                                return this.transfusionVolumeList[i].size;
                            }
                        }
                    },

                         // 将表格中bloodCount字段的size转换成code
                         getBloodSizeCode(name){
                        for (var i = 0; i < this.transfusionVolumeList.length; i++) {
                            if (this.transfusionVolumeList[i].size == name) { //dictValue，dictLabel保持和上面定义一致
                                return this.transfusionVolumeList[i].code;
                            }
                        }
                    },

                    // 获取输血申请字典
                getTransfusionType(){
                        axios.get('/bloodComposition/normal/getName')
                        .then((res)=>{
                            if (res.data.code === '200'){
                                this.transfusionTypeList = res.data.data
                            } else {
                                this.$notify.error({
                                    title : '错误',
                                    message : '获取数据失败'
                                })
                            }
                        })
                    },

                // 将表格中的transfusionType字段的code转换成name
                getTransfusionTypeName(code){
                    for (var i=0;i<this.transfusionTypeList.length;i++){
                        if (this.transfusionTypeList[i].code == code){
                            return this.transfusionTypeList[i].composition
                        }
                    }
                },



                 // 获取abo血型字典
                 getAboBloodType(){
                    axios.get('/aboType/normal/getName')
                        .then((res)=>{
                            if (res.data.code === '200') {
                                this.aboBloodTypeList = res.data.data
                            } else {
                                this.$notify.error({
                                    title: '错误',
                                    message: '获取数据失败',
                                })
                            }
                        })
                },

                 // 获取状态字典
                 getState(){
                        axios.get('/state/normal/getName')
                        .then((res)=>{
                            if (res.data.code === '200'){
                                this.stateList = res.data.data
                            } else {
                                this.$notify.error({
                                    title : '错误',
                                    message : '获取数据失败'
                                })
                            }
                        })
                    },

                    // 将表格中的State字段的code转换成name
                    getStateName(code){
                        for (var i=0;i<this.stateList.length;i++){
                            if (this.stateList[i].code == code){
                                return this.stateList[i].state
                            }
                        }
                    },

                
                    // 获取血液位置字典
                    getBloodLocation(){
                        axios.get('/bloodLocation/normal/getName')
                            .then((res)=>{
                                if (res.data.code === '200') {
                                    this.bloodLocationList = res.data.data
                                } else {
                                    this.$notify.error({
                                        title: '错误',
                                        message: '获取数据失败',
                                    })
                                }
                            })
                    },
                    // 将表格中bloodLocation字段的code转换成name
                    getBloodLocationName(code){
                        for (var i = 0; i < this.bloodLocationList.length; i++) {
                            if (this.bloodLocationList[i].code == code) { //dictValue，dictLabel保持和上面定义一致
                                return this.bloodLocationList[i].location;
                            }
                        }
                    },

                // 获取abo血型字典
                getAboBloodType(){
                    axios.get('/aboType/normal/getName')
                        .then((res)=>{
                            if (res.data.code === '200') {
                                this.aboBloodTypeList = res.data.data
                            } else {
                                this.$notify.error({
                                    title: '错误',
                                    message: '获取数据失败',
                                })
                            }
                        })
                },
                
                // 将表格中aboBloodType字段的code转换成name
                getAboBloodName(code){
                    for (var i = 0; i < this.aboBloodTypeList.length; i++) {
                        if (this.aboBloodTypeList[i].code == code) { //dictValue，dictLabel保持和上面定义一致
                            return this.aboBloodTypeList[i].name;
                        }
                    }
                },

                 // 获取rh血型字典
                 getRhBloodType(){
                    axios.get('/rhType/normal/getName')
                        .then((res)=>{
                            if (res.data.code === '200') {
                                this.rhBloodTypeList = res.data.data
                            } else {
                                this.$notify.error({
                                    title: '错误',
                                    message: '获取数据失败',
                                })
                            }
                        })
                },
                
                // 将表格中rhType字段的code转换成name
                getRhBloodName(code){
                    for (var i = 0; i < this.rhBloodTypeList.length; i++) {
                        if (this.rhBloodTypeList[i].code == code) { //dictValue，dictLabel保持和上面定义一致
                            return this.rhBloodTypeList[i].name;
                        }
                    }
                },

                // 获取血液成分字典
                getBloodComponent(){
                    axios.get('/bloodComposition/normal/getName')
                        .then((res)=>{
                            if (res.data.code === '200') {
                                this.bloodComponentList = res.data.data
                            } else {
                                this.$notify.error({
                                    title: '错误',
                                    message: '获取数据失败',
                                })
                            }
                        })
                },
                
                // 将表格中bloodComponent字段的code转换成name
                getBloodComponentName(code){
                    for (var i = 0; i < this.bloodComponentList.length; i++) {
                        if (this.bloodComponentList[i].code == code) { //dictValue，dictLabel保持和上面定义一致
                            return this.bloodComponentList[i].composition;
                        }
                    }
                },

                // 将表格中的bloodComponent字段的name转换成code
                getBloodComponentCode(name){
                    for (var i = 0; i < this.bloodComponentList.length; i++) {
                        if (this.bloodComponentList[i].composition == name) { //dictValue，dictLabel保持和上面定义一致
                            return this.bloodComponentList[i].code;
                        }
                    }
                },

                // 获取当前时间
                getNowTime(){
                    var date = new Date();
                    var year = date.getFullYear();
                    var month = date.getMonth()+1;
                    var day = date.getDate();
                    var hour = date.getHours();
                    var minute = date.getMinutes();
                    var second = date.getSeconds();

                    var time = year + '-' + this.handleTimeStr(month) + '-' +
                        this.handleTimeStr(day) + ' ' + this.handleTimeStr(hour) + ':' + this.handleTimeStr(minute)
                        + ':' + this.handleTimeStr(second);
                    return time;
                },

                // 解决 10:2:2 出现各位数字格式化为 10:02:02
                handleTimeStr(tStr){
                    if (tStr < 10){
                        return '0'+ tStr
                    }else {
                        return tStr
                    }
                },
            }
        });
    })()
</script>

</body>
</html>